package com.blackitheima1.LambdaDemo.test4;

import java.util.Random;

//Lambda表达式 无参有返回值
public class TestRandom {
    public static void main(String[] args) {
        //匿名内部类
        getRandom(new RandomDemo() {
            @Override
            public int getRa() {
                Random r=new Random();
                return r.nextInt(10)+1;
            }
        });
        //Lambda表达式
        getRandom(()->{
            Random r=new Random();
            return r.nextInt(10)+1;
        });

    }
    public static void getRandom(RandomDemo randomDemo){
        int result=randomDemo.getRa();
        System.out.println(result);
    }
}
//接口
interface RandomDemo{
    public abstract int getRa();
}
